export default {
  methods: {
    /**
     * 工作量撤回
     * @param data 返回得二进制流
     * @param name 下载文件名
     */
    back(id, callback, text = '是否撤回该条记录吗?', api = 'applyBack'){
      this.$confirm(text, {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(async () => {
        await this.$api[api](id)
        this.$message({
          type: "success",
          message: "操作成功!"
        });
        callback()
      }).catch(() => {
      })
    },
    /**
     * 共用确认框
     *
     */
    pubConfirm(text = '是否删除该条数据', callback){
      this.$confirm(text, {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(async () => {
        await callback()
        this.$message({
          type: "success",
          message: "操作成功!"
        });
      }).catch(() => {
      })
    },
    /**
     * 工作流预览共用确认框
     *
     */
    flowConfirm(text = '是否删除该条数据', callback, callback2){
      this.$confirm(text, '提示', {
        distinguishCancelAndClose: true,
        confirmButtonText: "下载",
        cancelButtonText: "预览",
        type: "warning",
        center: true,
        cancelButtonClass: 'btnFalses'
      }).then(async () => {
        await callback()
        this.$message({
          type: "success",
          message: "操作成功!"
        });
      }).catch(async (action) => {
        await callback2(action)
      })
    }
  },
}
